﻿
/*
 * Javasript based on Functions(JBF) 1.03
 * 
 * Copyright(c) 2010, Fooxee (JA86.CN)
 *
 * JBF is licensed under the terms of the Open Source GPL 3.0(http://www.gnu.org/licenses/gpl.html) license. 
 * 
 * JBF's blog: http://www.cnblogs.com/JBF/
 * 
 * Created by Fooxee. at 2010.03.08  mailTo:hjccjun@163.com
 */

//Cookie操作
JBF.Cookie=JBF.cookie={
	//设置
	set:function(sName, sValue, iHour)
	{
		var sCookie = sName + "=" + encodeURIComponent(sValue);
		if (iHour)
		{
			var oExpires = new Date( new Date().getTime() + iHour * 3600000);
			sCookie += "; expires=" + oExpires.toGMTString();
		}
		document.cookie = sCookie;
	},
	//获取
	get:function(sName)
	{
		var sRE = "(?:; )?" + sName + "=([^;]*);?";
		var oRE = new RegExp(sRE);
		if (oRE.test(document.cookie))
		{
			return decodeURIComponent(RegExp["$1"]);
		} 
		else
		{
			return null;
		}
	},
	//移除
	remove:function(sName)
	{
		this.set(sName,null,-9999*10);
	},
	//清除所有Cookie
	clear:function()
	{
		document.cookie=null;
	}
};
